﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMediaPlayer>
#include <QVideoWidget>
#include <QSlider>
#include <QPushButton>
#include <QListWidget>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFileDialog>
#include <QDir>
#include <QKeyEvent>

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    void keyPressEvent(QKeyEvent *event) override;

private slots:
    void openFolder();
    void playPause();
    void muteUnmute();
    void changeVolume(int value);
    void changePosition(int value);
    void updatePosition(qint64 position);
    void updateDuration(qint64 duration);
    void playNext();
    void playPrevious();
    void changePlaybackRate();
    void updateMediaInfo();

private:
    void setupUi();
    void loadVideos(const QString &folderPath);

    QMediaPlayer *mediaPlayer;
    QVideoWidget *videoWidget;
    QSlider *positionSlider;
    QSlider *volumeSlider;
    QPushButton *playPauseButton;
    QPushButton *muteButton;
    QPushButton *nextButton;
    QPushButton *previousButton;
    QPushButton *rateButton;
    QListWidget *playlistWidget;
    QLabel *currentTimeLabel;
    QLabel *totalTimeLabel;
    QLabel *videoNameLabel;

    QStringList videoFiles;
    int currentVideoIndex;
};
#endif // MAINWINDOW_H
